Repository navigation
fix(studio): agent tools see the film in a sealed preview - #8281
Conversation
…write and read back
Edit accuracy: accurate 271 (base branch 271), smooth 71 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (1)
|
eddy-heygen
left a comment
There was a problem hiding this comment.
(Eddy's agent) Reviewed by Eddy's Claude agent at commit 2c1b6c9 (full diff reviewed in a worktree; the new preview module read by hand).
Verdict: approve.
Summary
With a sealed preview (off by default), Studio's agent tools saw nothing because they read the frame's document directly. They now go through one new module that asks the frame's runtime over the existing port when the frame is sealed, and reads the document as before when it is not. Look, select, inspect, targeted writes and the read-back after a move, resize or text write all use it. Look reports "loading" until the player has a timeline.
What I checked
- Nothing new crosses the seal: the change is confined to the agent-tools folder and one end-to-end script. No runtime or port code changes and no new request kind; the tools reach the same layer, describe and query requests the editor's own selection already uses.
- Replies from the frame pass the existing shape checks before use, and the new code has no HTML sink. Handle validation and the write path's project-scope check are untouched.
- A read-back never measures Studio's stand-in: for a selection that names a frame element it returns the frame's answer or fails.
- With the preview unsealed (today's default) the paths reduce to the previous document reads.
Non-blockers
- A sealed look reads one page of layers and drops the "truncated" signal, so on a very large film elements past the first page are reported as absent. Page through, or surface truncation, before the sealed preview becomes the default.
- Setting text on a sealed selection still stops at "no editable text field"; the sealed text read-back is covered only by a test that builds the selection by hand. The description says so and names the follow-up.
- The "loading while duration is 0" rule also applies to unsealed previews and is computed in two places. I found no way the current runtime leaves the duration at 0 for a loaded film, so this is hardening only.
- In a sealed frame the values the tools return (labels, text, boxes, the file a write is addressed to) come from the frame, which runs beside the film's own scripts, so a film can misreport them. This is the same trust the existing sealed selection already places in the frame, not a widening.
CI: 63 pass, 16 skipped, none failing; 2 pending (Windows engine CLI tests, which do not cover the changed code). The Studio and runtime test jobs, including Windows Studio, passed.
What
In a sealed preview (Studio cannot script the frame), Studio's agent tools now see the film:
studio_looklists the scene, with the same handles a live preview gives. Before, it always saidloadingwith no elements.studio_select,studio_inspectand every targeted write (studio_set_style,studio_set_text,studio_transform, the animation tools) find the element a handle names. Before, each one answered "the preview is not mounted yet".studio_looksays the scene is stillloadinguntil the player has the film's timeline. In a sealed preview the timeline lands a round trip after the first seek answers, so an agent looking right after a seek read a duration of 0 and no clips.The sealed preview is off by default until the sealed-by-default change (#7846) lands, so nothing changes for anyone before then.
Why
The agent tools read
previewIframe.contentDocument, which is always null for a sealed frame. Studio already finds elements in a sealed frame through its runtime:findSelectionElement(a handle's element, or the frame's description of it) andcollectPreviewLayerItems(the layers list the Layers panel shows). The agent tools never went through them.How
webmcp/agentPreview.ts, the agent tools' one read of the preview, sealed or not:load: the preview's current load (its document, or the sealed frame's per-load port client);find: a handle's element, throughfindSelectionElement;readNow: an element's box and text as the preview shows them now;scene: the look scene, throughcollectPreviewLayerItemswhen sealed.resolveLiveHandleSelectiontakes that read instead of a document getter. It still reacquires once across a reload: a reload is a new load, and a stand-in stays held while its load does.buildSelectionalready accepted the frame's description (buildDomSelectionFromTarget), so selections are the same ones a click makes.readBoxbecomesreadNow;studio_set_textcompares the text it reads back instead of the selection's old node.buildStudioLookreportsloadingwhile the duration is 0. Every runtime timeline post carries at least 1 s.studio_look's ready scene instead of looking once.No new port requests.
Test plan
agentPreview.sealed.test.ts, on a sealed frame served by the real runtime agent:loadingand lists nothing.webmcptests now find elements through the same read (documentPreviewover a live document), and the box read's tests moved toreadNow.A sealed selection has no text fields yet, so the set_text test gives its selection one. The real one comes with #8156 (text fields over the port).
fails without the fix:
studio_lookready before the timeline posts, "says the scene is still loading" fails.Run on Linux: Studio
webmcp, topology lens and the public export tests (215) pass three runs in a row; Studiotscno errors; format clean; the code audit passes.Walk
The paused-video sockets walk (
undo-socket-pool.mjs) on a dev Studio, with this change on top of the sealed-by-default change:studio_look found no #target(sceneStatus: loading,duration: 0, no elements)A probe of
studio_lookright after the walk's first seek, before this change: sealed read a duration of 0 and no clips 1 ms after the seek and 20 s with 9 clips 267 ms later, with the sceneloadingthroughout; unsealed read 20 s, 9 clips and a ready scene at once.Before
Sealed preview (main, sealed preview switched on), the
inline-text-caretfixture, at 1 s. The agent looks, then selects#titleby its handle: the look saysloadingwith no elements and the select is refused, so nothing is selected.After
The same at this head: the look lists the scene's 3 elements, with the handles an unsealed preview gives, and the select finds
#title, which Studio shows selected.